package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test1 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Class cla=Class.forName("reflect.Person");


        Method[] methods=cla.getDeclaredMethods();
        Object obj=cla.newInstance();
        for (Method method:methods){
            if (method.getParameterCount()==0 && method.getModifiers()== Modifier.PUBLIC){
                method.invoke(obj);
            }

        }


    }
}
